<?php 

$socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP); 
$connection = socket_connect($socket, '10.10.83.234', 9500);  

//$send_data = "select * from user limit 0,10000";
echo "Input execute sql: ";
$send_data = trim(fgets(STDIN));

if (!socket_write($socket, "$send_data\n")) 
{ 
    echo "Send Sql Failed \n"; 
} 

while ($buffer = socket_read($socket, 65535, PHP_NORMAL_READ)) 
{ 
    echo  $buffer."\n" ; 
    if(substr($buffer, -1) == "\r"){break;}
}      

